{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [],
   "source": [
    "from __future__ import annotations\n",
    "from typing import TypeVar, Generic, NoReturn\n",
    "\n",
    "T = TypeVar(\"T\")\n",
    "\n",
    "\n",
    "class M(Generic[T]):\n",
    "    value: T\n",
    "    cnt: int = 1\n",
    "\n",
    "    def __init__(self, value: T) -> NoReturn:\n",
    "        self.value = value\n",
    "    \n",
    "    def __iter__(self) -> M:\n",
    "        return self\n",
    "\n",
    "    def __next__(self) -> T:\n",
    "        if self.cnt == 1:\n",
    "            self.cnt = 0\n",
    "            return self.value\n",
    "        else:\n",
    "            raise StopIteration"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[6]"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[i * 2 for i in M(*(i+ 1 for i in M(2)))]"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "b00d0533784e0bd7ec39dc1f12727fcf9021e9a985583666278f4fb55e7dfcf4"
  },
  "kernelspec": {
   "display_name": "Python 3.10.0 64-bit ('fppy2': conda)",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.0"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
